/**
 * Copyright (C) 2021-2022 maminjie <canpool@163.com>
 * SPDX-License-Identifier: LGPL-2.1
 * Powered by Qt-Advanced-Docking-System
**/

#pragma once

#include "qads_global.h"

#include <QScrollArea>

QADS_BEGIN_NAMESPACE

class DockPannel;
class DockTab;

class DockTabBarPrivate;

class QADS_EXPORT DockTabBar : public QScrollArea
{
    Q_OBJECT
public:
    DockTabBar(DockPannel *parent);
    ~DockTabBar() override;

    void insertTab(int index, DockTab *tab);
    void removeTab(DockTab *tab);
    void closeTab(int index);

    int count() const;

    int currentIndex() const;
    void setCurrentIndex(int index);

    DockTab *currentTab() const;
    DockTab *tab(int index) const;

    bool isTabVisible(int index) const;

    QSize minimumSizeHint() const override;
    QSize sizeHint() const override;

signals:
    void currentChanging(int index);
    void currentChanged(int index);
    void tabBarClicked(int index);
    void tabCloseRequested(int index);
    void tabClosed(int index);
    void tabOpened(int index);
    void tabMoved(int from, int to);
    void tabRemoving(int index);
    void tabInserted(int index);
    void tabElidedChanged(bool elided);

protected:
    bool eventFilter(QObject *watched, QEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;

private:
    void onTabClicked();
    void onTabCloseRequested();
    void onTabCloseOtherRequested();
    void onTabMoved(const QPoint &globalPos);

private:
    DockTabBarPrivate *d;
}; // class DockTabBar

QADS_END_NAMESPACE
